package misc.tracers;

import coloredtrails.client.ui.discourse.MakeBasicProposalWindow;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by pbh on Aug 20, 2005 at 4:18:56 AM.
 */
public class ProposalsWindow extends JFrame {
    private JPanel topPanel;
    private JButton newProposalButton;
    private JButton retractProposalButton;
    private JPanel mainPanel;
    private MakeBasicProposalWindow mpw = new MakeBasicProposalWindow();
    private ProposalListPanel plp = new ProposalListPanel();

    public ProposalsWindow() {

        setTitle("Proposals");
        setContentPane(mainPanel);
        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        setBackground(Color.white);
        mainPanel.setBackground(Color.white);
        topPanel.setBackground(Color.white);
        newProposalButton.requestFocus();

        topPanel.add(plp);
        newProposalButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                mpw.reset();
                mpw.setVisible(true);
            }
        });

        retractProposalButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.err.println("FUHUH: " + plp.getSelectedMessageId());
            }
        });

        pack();
    }

    public ProposalListPanel getProposalListPanel() {
        return plp;
    }

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// !!! IMPORTANT !!!
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * !!! IMPORTANT !!!
     * DO NOT edit this method OR call it in your code!
     */
    private void $$$setupUI$$$() {
        mainPanel = new JPanel();
        mainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0,
                0, 0), -1,
                -1));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0,
                0), -1,
                -1));
        mainPanel.add(panel1,
                new GridConstraints(1, 0, 1, 1,
                        GridConstraints.ANCHOR_CENTER,
                        GridConstraints.FILL_BOTH,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        null, null, null));
        newProposalButton = new JButton();
        newProposalButton.setText("New Proposal...");
        newProposalButton.setToolTipText("Make a new proposal");
        panel1.add(newProposalButton,
                new GridConstraints(0, 0, 1, 1,
                        GridConstraints.ANCHOR_CENTER,
                        GridConstraints.FILL_HORIZONTAL,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        GridConstraints.SIZEPOLICY_FIXED, null, null,
                        null));
        retractProposalButton = new JButton();
        retractProposalButton.setText("Retract Proposal");
        retractProposalButton.setToolTipText("Retract selected proposal");
        panel1.add(retractProposalButton,
                new GridConstraints(0, 1, 1, 1,
                        GridConstraints.ANCHOR_CENTER,
                        GridConstraints.FILL_HORIZONTAL,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        GridConstraints.SIZEPOLICY_FIXED, null, null,
                        null));
        topPanel = new JPanel();
        mainPanel.add(topPanel,
                new GridConstraints(0, 0, 1, 1,
                        GridConstraints.ANCHOR_CENTER,
                        GridConstraints.FILL_BOTH,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        null, null, null));
    }
}
